﻿using FlowCanvas;
using FlowCanvas.Nodes;
using LogSystem;
using NodeCanvas.Framework;
using ParadoxNotion.Design;

namespace Yoozoo.Gameplay.Liberty.Nodes
{
    [Category("Ggame")]
    public class AddFeatureAirWall : CallableActionNodeBase
    {
        protected override void OnRegisterPorts(FlowNode node)
        {
            var o = node.AddFlowOutput("In");
            var p1 = node.AddValueInput<string>("wallName");
            var p2 = node.AddValueInput<string>("pointName");
            
            node.AddFlowInput("Out", (Flow f) => { Invoke(p1.value, p2.value); o.Call(f); });
        }

        private void Invoke(string wallName, string pointName)
        {
            wallName = wallName.Trim();
            pointName = pointName.Trim();

            BluePrintPoint point = BlueprintUtils.GetBlueprintPoint(pointName);
            if (point!=null)
            {
                BlueprintUtils.AddFeatureAirWall(wallName,point.position,point.rotation,point.lossyScale);
            }
            else
            {
                Debug.LogError(LogModule.Blueprint,"找不到蓝图点位：" + pointName);
            }
        }
    }
}